

<!doctype html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>skidl.config_ &#8212; SKiDL 2.2.0 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=a66e137f" />
    
    <script src="../../_static/documentation_options.js?v=b21de401"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/bizstyle.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <!--[if lt IE 9]>
    <script src="_static/css3-mediaqueries.js"></script>
    <![endif]-->
  </head><body>
    <h1 id="site-title"><a href="../../../../"><img src="../../../../images/slim_banner.png" width="100%"></a></h1>
    
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 2.2.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.config_</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for skidl.config_</h1><div class="highlight"><pre>
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>

<span class="c1"># The MIT License (MIT) - Copyright (c) Dave Vandenbout.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Configuration management for SKiDL.</span>

<span class="sd">This module provides classes for loading, storing, and accessing SKiDL configuration</span>
<span class="sd">parameters. Configuration data is stored in JSON files and includes settings for</span>
<span class="sd">default tools, library search paths, footprint search paths, and backup library options.</span>
<span class="sd">The module supports configuration hierarchies with system, user, and project-specific </span>
<span class="sd">settings that are merged according to priority.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">os.path</span>
<span class="kn">import</span> <span class="nn">sys</span>

<span class="kn">from</span> <span class="nn">.logger</span> <span class="kn">import</span> <span class="n">active_logger</span>
<span class="kn">from</span> <span class="nn">.part_query</span> <span class="kn">import</span> <span class="n">footprint_cache</span>
<span class="kn">from</span> <span class="nn">.scriptinfo</span> <span class="kn">import</span> <span class="n">get_script_name</span>
<span class="kn">from</span> <span class="nn">.tools</span> <span class="kn">import</span> <span class="n">ALL_TOOLS</span><span class="p">,</span> <span class="n">lib_suffixes</span><span class="p">,</span> <span class="n">tool_modules</span>
<span class="kn">from</span> <span class="nn">.utilities</span> <span class="kn">import</span> <span class="n">TriggerDict</span><span class="p">,</span> <span class="n">export_to_all</span><span class="p">,</span> <span class="n">merge_dicts</span><span class="p">,</span> <span class="n">expand_path</span>

<span class="k">def</span> <span class="nf">_get_default_skidl_storage_dir</span><span class="p">():</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Return path to a platform-appropriate per-user directory for persistent SKiDL data.</span>

<span class="sd">    Linux/Unix: XDG_DATA_HOME/skidl or ~/.local/share/skidl</span>
<span class="sd">    macOS: ~/Library/Application Support/skidl</span>
<span class="sd">    Windows: %APPDATA%/skidl or %LOCALAPPDATA%/skidl (fallback to ~/AppData/Roaming/skidl)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># Determine the base directory for storing SKiDL data for a given OS.</span>
    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;nt&quot;</span><span class="p">:</span>
        <span class="n">appdata</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;APPDATA&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;LOCALAPPDATA&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">appdata</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">appdata</span><span class="p">,</span> <span class="s2">&quot;skidl&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~&quot;</span><span class="p">),</span> <span class="s2">&quot;AppData&quot;</span><span class="p">,</span> <span class="s2">&quot;Roaming&quot;</span><span class="p">,</span> <span class="s2">&quot;skidl&quot;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">xdg</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;XDG_DATA_HOME&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">xdg</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">xdg</span><span class="p">,</span> <span class="s2">&quot;skidl&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span> <span class="o">==</span> <span class="s2">&quot;darwin&quot;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~&quot;</span><span class="p">),</span> <span class="s2">&quot;Library&quot;</span><span class="p">,</span> <span class="s2">&quot;Application Support&quot;</span><span class="p">,</span> <span class="s2">&quot;skidl&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s2">&quot;~&quot;</span><span class="p">),</span> <span class="s2">&quot;.local&quot;</span><span class="p">,</span> <span class="s2">&quot;share&quot;</span><span class="p">,</span> <span class="s2">&quot;skidl&quot;</span><span class="p">)</span>

<div class="viewcode-block" id="Config">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.Config">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">class</span> <span class="nc">Config</span><span class="p">(</span><span class="nb">dict</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Base class for managing configuration parameters.</span>
<span class="sd">    </span>
<span class="sd">    This class extends the dictionary to store configuration parameters and provides</span>
<span class="sd">    methods to load configuration from JSON files and save it back to disk.</span>
<span class="sd">    Configuration from multiple sources can be merged with intelligent handling</span>
<span class="sd">    of nested dictionaries.</span>
<span class="sd">    </span>
<span class="sd">    Args:</span>
<span class="sd">        cfg_file_name (str): Name of the configuration file.</span>
<span class="sd">        *dirs: Directories to search for configuration files.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cfg_file_name</span><span class="p">,</span> <span class="o">*</span><span class="n">dirs</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cfg_file_name</span> <span class="o">=</span> <span class="n">cfg_file_name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="o">*</span><span class="n">dirs</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Access configuration values as attributes.</span>
<span class="sd">        </span>
<span class="sd">        This enables dot notation access to configuration parameters in addition</span>
<span class="sd">        to dictionary-style access.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            key (str): The configuration parameter name.</span>
<span class="sd">            </span>
<span class="sd">        Returns:</span>
<span class="sd">            The value of the configuration parameter.</span>
<span class="sd">            </span>
<span class="sd">        Raises:</span>
<span class="sd">            AttributeError: If the key doesn&#39;t exist in the configuration.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">AttributeError</span>

    <span class="k">def</span> <span class="fm">__setattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set configuration values as attributes and dictionary entries.</span>
<span class="sd">        </span>
<span class="sd">        This ensures that attribute-style and dictionary-style access and</span>
<span class="sd">        modification are synchronized.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            key (str): The configuration parameter name.</span>
<span class="sd">            value: The value to assign to the parameter.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>

<div class="viewcode-block" id="Config.merge">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.Config.merge">[docs]</a>
    <span class="k">def</span> <span class="nf">merge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">merge_dct</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Merge another dictionary into this configuration.</span>
<span class="sd">        </span>
<span class="sd">        This method recursively merges dictionaries, preserving nested structures</span>
<span class="sd">        where possible.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            merge_dct (dict): Dictionary to merge into this configuration.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">merge_dct</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
            <span class="k">if</span> <span class="p">(</span>
                <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span>
                <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="nb">dict</span><span class="p">)</span>
                <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">merge_dct</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">collections</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">Mapping</span><span class="p">)</span>
            <span class="p">):</span>
                <span class="n">merge_dicts</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">merge_dct</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">merge_dct</span><span class="p">[</span><span class="n">k</span><span class="p">]</span></div>


<div class="viewcode-block" id="Config.load">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.Config.load">[docs]</a>
    <span class="k">def</span> <span class="nf">load</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dirs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Load configuration from JSON files in the specified directories.</span>
<span class="sd">        </span>
<span class="sd">        This method looks for the configuration file in each directory and merges</span>
<span class="sd">        the settings found in each file, with later directories taking precedence.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            *dirs: Directories to search for configuration files.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="nb">dir</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span>
            <span class="n">path</span> <span class="o">=</span> <span class="n">expand_path</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg_file_name</span><span class="p">))</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="k">as</span> <span class="n">cfg_fp</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">cfg_fp</span><span class="p">))</span>
            <span class="k">except</span> <span class="p">(</span><span class="ne">FileNotFoundError</span><span class="p">,</span> <span class="ne">IOError</span><span class="p">):</span>
                <span class="k">pass</span></div>


<div class="viewcode-block" id="Config.store">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.Config.store">[docs]</a>
    <span class="k">def</span> <span class="nf">store</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Store the current configuration as a JSON file.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            dir (str, optional): Directory to store the configuration file in.</span>
<span class="sd">                Defaults to the current directory.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">path</span> <span class="o">=</span> <span class="n">expand_path</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">dir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg_file_name</span><span class="p">))</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">cfg_fp</span><span class="p">:</span>
            <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cfg_fp</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span></div>
</div>



<div class="viewcode-block" id="SkidlConfig">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.SkidlConfig">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">class</span> <span class="nc">SkidlConfig</span><span class="p">(</span><span class="n">Config</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Configuration class specialized for SKiDL.</span>
<span class="sd">    </span>
<span class="sd">    This class extends the base Config class with SKiDL-specific defaults and</span>
<span class="sd">    behaviors, such as managing tool selection, library paths, and footprint paths.</span>
<span class="sd">    </span>
<span class="sd">    Args:</span>
<span class="sd">        tool (str): Default tool/backend to use if not specified in config files.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tool</span><span class="p">):</span>
        <span class="kn">from</span> <span class="nn">skidl</span> <span class="kn">import</span> <span class="n">SKIDL</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span> <span class="o">=</span> <span class="n">_get_default_skidl_storage_dir</span><span class="p">()</span>

        <span class="c1"># Load the .skidlcfg file from one of the list of directories.</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="s2">&quot;.skidlcfg&quot;</span><span class="p">,</span> <span class="s2">&quot;/etc&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span><span class="p">,</span> <span class="s2">&quot;.&quot;</span><span class="p">)</span>

        <span class="c1"># Make the directory for storing persistent SKiDL data if it doesn&#39;t exist.</span>
        <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="c1"># If no configuration files were found, set default backend/tool.</span>
        <span class="k">if</span> <span class="s2">&quot;tool&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">tool</span> <span class="o">=</span> <span class="n">tool</span>

        <span class="c1"># If no configuration files were found, set default directory for part library pickle files.</span>
        <span class="k">if</span> <span class="s2">&quot;pickle_dir&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pickle_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span><span class="p">,</span> <span class="s2">&quot;lib_pickle_dir&quot;</span><span class="p">)</span>
        <span class="c1"># Make the directory.</span>
        <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pickle_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="c1"># If no configuration files were found, set default directory for part search database.</span>
        <span class="k">if</span> <span class="s2">&quot;part_search_db_dir&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">part_search_db_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span>
        <span class="c1"># Make the directory.</span>
        <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">part_search_db_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="c1"># If no configuration files were found, set some default part lib search paths.</span>
        <span class="k">if</span> <span class="s2">&quot;lib_search_paths&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="p">[</span><span class="s2">&quot;lib_search_paths&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">tool</span><span class="p">:</span> <span class="n">tool_modules</span><span class="p">[</span><span class="n">tool</span><span class="p">]</span><span class="o">.</span><span class="n">default_lib_paths</span><span class="p">()</span> <span class="k">for</span> <span class="n">tool</span> <span class="ow">in</span> <span class="n">ALL_TOOLS</span>
            <span class="p">}</span>

        <span class="c1"># If no configuration files were found, set base name of default backup part library.</span>
        <span class="k">if</span> <span class="s2">&quot;backup_lib_name&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">backup_lib_name</span> <span class="o">=</span> <span class="n">get_script_name</span><span class="p">()</span>
        <span class="k">if</span> <span class="s2">&quot;backup_lib_file_name&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">backup_lib_file_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">backup_lib_name</span> <span class="o">+</span> <span class="n">lib_suffixes</span><span class="p">[</span><span class="n">SKIDL</span><span class="p">]</span>
        <span class="k">if</span> <span class="s2">&quot;query_backup_lib&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">query_backup_lib</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">if</span> <span class="s2">&quot;backup_lib&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">backup_lib</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># If no configuration files were found, set some default footprint search paths.</span>
        <span class="k">if</span> <span class="s2">&quot;footprint_search_paths&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="bp">self</span><span class="p">[</span><span class="s2">&quot;footprint_search_paths&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">tool</span><span class="p">:</span> <span class="n">tool_modules</span><span class="p">[</span><span class="n">tool</span><span class="p">]</span><span class="o">.</span><span class="n">get_fp_lib_tbl_dir</span><span class="p">()</span> <span class="k">for</span> <span class="n">tool</span> <span class="ow">in</span> <span class="n">ALL_TOOLS</span>
            <span class="p">}</span>

        <span class="c1"># Cause the footprint cache to be invalidated if the footprint search path changes.</span>
        <span class="k">def</span> <span class="nf">invalidate_footprint_cache</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">):</span>
            <span class="n">footprint_cache</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>

        <span class="bp">self</span><span class="p">[</span><span class="s2">&quot;footprint_search_paths&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">TriggerDict</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s2">&quot;footprint_search_paths&quot;</span><span class="p">])</span>
        <span class="bp">self</span><span class="p">[</span><span class="s2">&quot;footprint_search_paths&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">trigger_funcs</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">tool</span><span class="p">]</span> <span class="o">=</span> <span class="n">invalidate_footprint_cache</span>

<div class="viewcode-block" id="SkidlConfig.store">
<a class="viewcode-back" href="../../rst_output/skidl.config_.html#skidl.config_.SkidlConfig.store">[docs]</a>
    <span class="k">def</span> <span class="nf">store</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Store the current SKiDL configuration as a JSON file.</span>
<span class="sd">        </span>
<span class="sd">        Args:</span>
<span class="sd">            dir (str, optional): Directory to store the configuration file in.</span>
<span class="sd">                Defaults to the SKiDL storage directory.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">dir</span> <span class="o">=</span> <span class="nb">dir</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">skidl_storage_dir</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">store</span><span class="p">(</span><span class="nb">dir</span><span class="p">)</span></div>
</div>

</pre></div>

            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 2.2.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.config_</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright 2016-2025, Dave Vandenbout.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
    </div>
  </body>
</html>